dict1 = {'name': 'TOM', 'age': 20, 'gender': '男'}

# del 删除字典或指定的键值对
# del(dict1)
# print(dict1) #NameError: name 'dict1' is not defined. Did you mean: 'dict'?


del dict1['name']
"""
   del dict1['names']  # 报错
        ~~~~~^^^^^^^^^
KeyError: 'names'
python-BaseException
"""
# del dict1['names']  # 报错
print(dict1) #{'age': 20, 'gender': '男'}

# clear()
dict1.clear()
print(dict1) #{}

